$(function(){
	$('a').focus(function(){this.blur();});
	SI.Files.stylizeAll();
	slider.init();
});
var slider={
	num:-1,
	cur:0,
	cr:[],
	al:null,
	at:10*1000,
	ar:true,
	init:function(){
		if(!slider.data || !slider.data.length) return false;
		
		var d=slider.data;
		slider.num=d.length;
		var pos=Math.floor(Math.random()*1);
		for(var i=0;i<slider.num;i++){
		   $('#'+d[i].id).css({left:((i-pos)*1000)});
		   $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();"></a>');
		}
		slider.on(pos);
		slider.cur=pos;
		window.setTimeout('slider.auto();',slider.at);
	},
	auto:function(){
		if(!slider.ar) return false;
		
		var next=slider.cur+1;
		if(next>=slider.num) next=0;
		slider.slide(next);
	},
	slide:function(pos){
		if(pos<0 || pos>=slider.num || pos==slider.cur) return;
		
		window.clearTimeout(slider.al);
		slider.al=window.setTimeout('slider.auto();',slider.at);
		
		var d=slider.data;
		for(var i=0;i<slider.num;i++)
			$('#'+d[i].id).stop().animate({left:((i-pos)*1000)},1000,'swing');
		
		slider.on(pos);
		slider.cur=pos;
	},
	on:function(pos){
		$('#slide-nav a').removeClass('on');
		$('#slide-nav a#slide-link-'+pos).addClass('on');
	},
	text:function(di){
		slider.cr['a']=di.client;
		slider.cr['b']=di.desc;
	},
	ticker:function(el,text,pos,unique){
		if(slider.cr[unique]!=text) return false;
		
		ctext=text.substring(0,pos)+(pos%2?'-':'_');
		$(el).html(ctext);
		
		if(pos==text.length)
			$(el).html(text);
		else
			window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");',30);
	}
};

if(!window.SI){var SI={};};
SI.Files={
	htmlClass:'SI-FILES-STYLIZED',
	fileClass:'file',
	wrapClass:'cabinet',
	
	fini:false,
	able:false,
	init:function(){
		this.fini=true;
	},
	stylize:function(elem){
		if(!this.fini){this.init();};
		if(!this.able){return;};
		
		elem.parentNode.file=elem;
		elem.parentNode.onmousemove=function(e){
			if(typeof e=='undefined') e=window.event;
			if(typeof e.pageY=='undefined' &&  typeof e.clientX=='number' && document.documentElement){
				e.pageX=e.clientX+document.documentElement.scrollLeft;
				e.pageY=e.clientY+document.documentElement.scrollTop;
			};
			var ox=oy=0;
			var elem=this;
			if(elem.offsetParent){
				ox=elem.offsetLeft;
				oy=elem.offsetTop;
				while(elem=elem.offsetParent){
					ox+=elem.offsetLeft;
					oy+=elem.offsetTop;
				};
			};
		};
	},
	stylizeAll:function(){
		if(!this.fini){this.init();};
		if(!this.able){return;};
	}
};